package cn.iocoder.yudao.module. enterprise.controller.admin.studentEducationalExperience;

import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.*;

import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;

import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;

import cn.iocoder.yudao.module. enterprise.controller.admin.studentEducationalExperience.vo.*;
import cn.iocoder.yudao.module. enterprise.dal.dataobject.studentEducationalExperience.EnterpriseStudentEducationalExperienceDO;
import cn.iocoder.yudao.module. enterprise.convert.studentEducationalExperience.EnterpriseStudentEducationalExperienceConvert;
import cn.iocoder.yudao.module. enterprise.service.studentEducationalExperience.EnterpriseStudentEducationalExperienceService;

@Api(tags = "管理后台 - 用户简历教育经历")
@RestController
@RequestMapping("/ enterprise/enterprise-student-educational-experience")
@Validated
public class EnterpriseStudentEducationalExperienceController {

    @Resource
    private EnterpriseStudentEducationalExperienceService enterpriseStudentEducationalExperienceService;

    @PostMapping("/create")
    @ApiOperation("创建用户简历教育经历")
    @PreAuthorize("@ss.hasPermission(' enterprise:enterprise-student-educational-experience:create')")
    public CommonResult<Long> createEnterpriseStudentEducationalExperience(@Valid @RequestBody EnterpriseStudentEducationalExperienceCreateReqVO createReqVO) {
        return success(enterpriseStudentEducationalExperienceService.createEnterpriseStudentEducationalExperience(createReqVO));
    }

    @PutMapping("/update")
    @ApiOperation("更新用户简历教育经历")
    @PreAuthorize("@ss.hasPermission(' enterprise:enterprise-student-educational-experience:update')")
    public CommonResult<Boolean> updateEnterpriseStudentEducationalExperience(@Valid @RequestBody EnterpriseStudentEducationalExperienceUpdateReqVO updateReqVO) {
        enterpriseStudentEducationalExperienceService.updateEnterpriseStudentEducationalExperience(updateReqVO);
        return success(true);
    }

    @DeleteMapping("/delete")
    @ApiOperation("删除用户简历教育经历")
    @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
    @PreAuthorize("@ss.hasPermission(' enterprise:enterprise-student-educational-experience:delete')")
    public CommonResult<Boolean> deleteEnterpriseStudentEducationalExperience(@RequestParam("id") Long id) {
        enterpriseStudentEducationalExperienceService.deleteEnterpriseStudentEducationalExperience(id);
        return success(true);
    }

    @GetMapping("/get")
    @ApiOperation("获得用户简历教育经历")
    @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
    @PreAuthorize("@ss.hasPermission(' enterprise:enterprise-student-educational-experience:query')")
    public CommonResult<EnterpriseStudentEducationalExperienceRespVO> getEnterpriseStudentEducationalExperience(@RequestParam("id") Long id) {
        EnterpriseStudentEducationalExperienceDO enterpriseStudentEducationalExperience = enterpriseStudentEducationalExperienceService.getEnterpriseStudentEducationalExperience(id);
        return success(EnterpriseStudentEducationalExperienceConvert.INSTANCE.convert(enterpriseStudentEducationalExperience));
    }

    @GetMapping("/list")
    @ApiOperation("获得用户简历教育经历列表")
    @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
    @PreAuthorize("@ss.hasPermission(' enterprise:enterprise-student-educational-experience:query')")
    public CommonResult<List<EnterpriseStudentEducationalExperienceRespVO>> getEnterpriseStudentEducationalExperienceList(@RequestParam("ids") Collection<Long> ids) {
        List<EnterpriseStudentEducationalExperienceDO> list = enterpriseStudentEducationalExperienceService.getEnterpriseStudentEducationalExperienceList(ids);
        return success(EnterpriseStudentEducationalExperienceConvert.INSTANCE.convertList(list));
    }

    @GetMapping("/page")
    @ApiOperation("获得用户简历教育经历分页")
    @PreAuthorize("@ss.hasPermission(' enterprise:enterprise-student-educational-experience:query')")
    public CommonResult<PageResult<EnterpriseStudentEducationalExperienceRespVO>> getEnterpriseStudentEducationalExperiencePage(@Valid EnterpriseStudentEducationalExperiencePageReqVO pageVO) {
        PageResult<EnterpriseStudentEducationalExperienceDO> pageResult = enterpriseStudentEducationalExperienceService.getEnterpriseStudentEducationalExperiencePage(pageVO);
        return success(EnterpriseStudentEducationalExperienceConvert.INSTANCE.convertPage(pageResult));
    }

    @GetMapping("/export-excel")
    @ApiOperation("导出用户简历教育经历 Excel")
    @PreAuthorize("@ss.hasPermission(' enterprise:enterprise-student-educational-experience:export')")
    @OperateLog(type = EXPORT)
    public void exportEnterpriseStudentEducationalExperienceExcel(@Valid EnterpriseStudentEducationalExperienceExportReqVO exportReqVO,
              HttpServletResponse response) throws IOException {
        List<EnterpriseStudentEducationalExperienceDO> list = enterpriseStudentEducationalExperienceService.getEnterpriseStudentEducationalExperienceList(exportReqVO);
        // 导出 Excel
        List<EnterpriseStudentEducationalExperienceExcelVO> datas = EnterpriseStudentEducationalExperienceConvert.INSTANCE.convertList02(list);
        ExcelUtils.write(response, "用户简历教育经历.xls", "数据", EnterpriseStudentEducationalExperienceExcelVO.class, datas);
    }

}
